#pragma once

#include "fxcc/imgui/pch.h"
#include "fxcc/imgui/Editor.h"
#include "fxcc/imgui/Label.h"
#include "fxcc/core/Base.h"
#include "glm/glm.hpp"


namespace fxcc
{
    namespace imgui
    {
        struct FXCC_API Layer
        {
            fxcc::imgui::Editor m_Editor;

            bool m_Open{true};
            
            bool m_Rendering{true};
            
            bool m_IsFocused{false};
            
            bool m_IsHovered{false};

            bool m_IsAnyItemHovered{ false };

            bool m_IsAnyItemActive{ false };
            
            bool m_IsAnyItemFocused{ false };

            
            ImVec2 m_WindowSize{};
            
            ImVec2 m_WindowPos{};

            std::string m_Title{ "[NULL]" };
            ImGuiWindowFlags m_Flag;

            Layer() = default;
            
            Layer(const std::string& title, ImGuiWindowFlags flag = 0);

            bool MenuItem();

            virtual void ViewFunc();

            virtual void HandleFunc();
            
            virtual void HandleSelection();

            void OnMarqueeSelection();

            virtual bool GetMarqueeSelectionFlag();

            void Inst();
            
            void Handle();
            
            virtual void OnDestroy();

            bool IsMouseOnWindow();
        
            std::vector<std::shared_ptr<fxcc::imgui::Layer>> m_Children;

            bool m_MarqueeSelection = false;

            ImVec2 m_PosMin, m_PosMax;

            void GetItemPos(ImVec2& minPos, ImVec2& maxPos);

            void GetItemPos(fxcc::Base* item);

            bool ItemInSelectionRange(const fxcc::Base* item);

        };
    };
};